<?php

namespace IDock\Insurance\HBIC\Response;

use Exception;
use IDock\Http\Response;
use IDock\IDock\IDockEnums;
use IDock\Insurance\HBIC\HBICEnums;
use IDock\Printer\EPolicyDownloadPrinter;
use IDock\Printer\Premium\PremiumBIPrinter;
use IDock\Printer\Premium\PremiumCIPrinter;
use IDock\Printer\Premium\PremiumCoveragePrinter;
use IDock\Printer\Premium\PremiumInquiryPrinter;
use IDock\Printer\Premium\PremiumTaxPrinter;
use IDock\Printer\PremiumUnderwritingPrinter;
use IDock\Printer\VehiclePrinter;

class DownloadInsuranceResponse extends AllHBICResponse
{

    public function resolve(): Response
    {
        return $this;
    }

    public function printerInit(): Response
    {
        $data = $this->getBody();
        $proposalRecallPrinter = new EPolicyDownloadPrinter();
        if(substr($data,0,4) != '%PDF'){
            $this->setError("获取电子保单失败");
            $this->printer = $proposalRecallPrinter;
            return $this;
        }
        $proposalRecallPrinter->data = $data;
        $proposalRecallPrinter->finish = (bool)$data;
        $proposalRecallPrinter->doing = false;
        $this->printer = $proposalRecallPrinter;
        return $this;
    }
}
